package jp.team.nature.reizoukoapp.db;

import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;

public class SQLOpenHelper extends SQLiteOpenHelper {

    final static private int DB_VERSION = 1;

    public SQLOpenHelper(Context context) {
        super(context, "zaiko_db", null, DB_VERSION);
    }

    // Create Table
    @Override
    public void onCreate(SQLiteDatabase db) {
        // table create
        db.execSQL(
            "create table zaiko_table(" +
            "id integer primary key, " +
            "category text , " +
            "name text not null, " +
            "quantity real , " +
            "unit text, " +
            "buydate text, " +
            "expdate text );"
        );

        // table row insert
        // for debug
        //db.execSQL("insert into zaiko_table(id, category, name, quantity, buydate, expdate) " +
        //	   "values (1, '肉', 'たわし', 1000, '20150101', '20150201');");
        //db.execSQL("insert into zaiko_table(id, category, name, quantity, buydate, expdate) " +
     	//	   "values (2, '肉', 'のらねこ', 2000, '20150201', '20150205');");
        //db.execSQL("insert into zaiko_table(id, category, name, quantity, buydate, expdate) " +
     	//	   "values (3, '魚介類', 'さかなクン', 100000, '20150201', '20150212');");
    }

    @Override
    public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
        //
    }

}
